package mkis.service.root.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import mkis.service.root.data.model.BizMng;
import mkis.service.root.service.BizMngService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class BizMngCTR {
	
	
	@Resource(name="bizMngService")
	private BizMngService bizMngService;
	
	@RequestMapping(value="/biz/biz_hist_mng.do")
	public ModelAndView mngList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mav=new ModelAndView("biz/biz_hist_mng");
		
		List<BizMng> list=bizMngService.getMngList();
		
		mav.addObject("list", list);
		
		return mav;
	}
	
	
	@RequestMapping(value="/biz/biz_hist_edit.do")
	public ModelAndView mngEdit(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mav=new ModelAndView("biz/biz_hist_edit_complete");
		
		Map<String,Object> paramMap=new HashMap<String,Object>();
		
		for(int i=1;i<=6;i++){
			String noKey="bizNo"+i;
			String nameKey="bizName"+i;
			paramMap.put(noKey, request.getParameter(noKey));
			paramMap.put(nameKey, request.getParameter(nameKey));
		}
		int result=bizMngService.updateMngList(paramMap);
		
		return mav;
	}
}
